<template>
  <div class="box1">
    <div class="title">
      <p>男女比例</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="sex">
      <div class="man">
        <img src="../../images/man.png" alt="" />
      </div>
      <div class="woman">
        <img src="../../images/woman.png" alt="" />
      </div>
    </div>
    <div class="rate">
      <p>男士58%</p>
      <p>女士42%</p>
    </div>
    <div class="charts" ref="charts" style="margin: 0px 10px"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
let charts = ref()

onMounted(() => {
  let myCharts = echarts.init(charts.value)
  myCharts.setOption({
    title: {
      text: '男女比例',
      textStyle: {
        color: 'white',
      },
      left: '41%',
    },
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      show: false,
      type: 'category',
    },
    series: [
      {
        type: 'bar',
        data: [58],
        barWidth: 20,
        itemStyle: {
          color: '#29fcff',
          //圆角
          borderRadius: 20,
        },
        //调整层级，防止柱被覆盖
        z: 3,
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        //调整女士柱条位置
        barGap: '-100%',
        itemStyle: {
          color: 'pink',
          //圆角
          borderRadius: 20,
        },
        z: 2,
      },
    ],
    grid: {
      top: 0,
      right: 0,
      bottom: 0,
      left: 0,
    },
  })
})
</script>

<style scoped lang="scss">
.box1 {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  margin: 5px 0px;
  .title {
    margin-top: 10px;
    margin-left: 20px;
    color: white;
    font-size: 18px;
  }
  .sex {
    margin: 50px 130px 0px 130px;
    display: flex;
    justify-content: space-between;
    .man {
      width: 111px;
      height: 115px;
      text-align: center;
      line-height: 115px;
      background: url('../../images/man-bg.png') no-repeat;
    }
    .woman {
      width: 111px;
      height: 115px;
      text-align: center;
      line-height: 115px;
      background: url('../../images/woman-bg.png') no-repeat;
    }
  }
  .rate {
    margin: 0px 20px;
    display: flex;
    justify-content: space-between;
    color: white;
  }
  .charts {
    width: 100%;
    height: 100px;
  }
}
</style>
